package pri.abner.atomikos.service.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pri.abner.atomikos.customer.CustomerMapper;
import pri.abner.atomikos.stores.StoresMapper;
import pri.abner.atomikos.entity.Consume;
import pri.abner.atomikos.service.TransferService;

/**
 * @description 
 * @author  Abner Chow
 * @date Created in 2018/11/22 17:44
 * @version v1.0.0
 */
@Service
public class TransferServiceImpl implements TransferService {


    @Autowired
    private CustomerMapper customerMapper;

    @Autowired
    private StoresMapper storesMapper;


    @Transactional
    @Override
    public void transfer(Consume consume) {
        customerMapper.addConsume(consume.getType(), consume.getMoney());
        //测试事务是否统一，打开下面注释
        // int a =100/0;
        storesMapper.addConsume(consume.getType(),consume.getMoney());
    }
}
